package com.huaxin.hxcloud.Adapter;

import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.huaxin.common.Entity.RepairTaskDetailDTO;
import com.huaxin.hxcloud.R;

/**
 * @author songxf
 * @date 2018/7/13
 * @Desc 添加药剂
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxMedicineAdapter extends BaseQuickAdapter<RepairTaskDetailDTO.Data.medicineTypeSel, BaseViewHolder> {
    private int mWorkTaskState;

    public HxMedicineAdapter() {
        super(R.layout.item_medicine_config);
    }

    public void setWorkTaskState(int workTaskState) {
        this.mWorkTaskState = workTaskState;

    }

    @Override
    protected void convert(BaseViewHolder helper, final RepairTaskDetailDTO.Data.medicineTypeSel item) {
        TextView nameTv = helper.getView(R.id.name_tv);
        TextView unitTv = helper.getView(R.id.unit_tv);
        EditText numberEt = helper.getView(R.id.number_et);
        //站点巡检单状态:0、未派工;1、已派工;2、处理中; 3已完成
        switch (mWorkTaskState) {
            case 0:
            case 1:
            case 3:
            default:
                numberEt.setEnabled(false);
                break;
            case 2:
                numberEt.setEnabled(true);
                break;

        }
        nameTv.setText(item.getMedicineName());
        unitTv.setText(item.getUnit());
        numberEt.setText(item.getNumber());
        numberEt.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence text, int start, int before, int count) {


            }

            @Override
            public void beforeTextChanged(CharSequence text, int start, int count, int after) {


            }

            @Override
            public void afterTextChanged(Editable edit) {
                //edit  输入结束呈现在输入框中的信息
                item.setNumber(edit.toString());
                Log.d("----afterTextChanged--", "" + edit.toString());
            }
        });
    }
}
